package com.ggs.rg.ybjb.systemmodule.service;

import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName:ConsumerService
 * Package:com.ggs.rg.ybjb.systemmodule.service
 * Description:
 * 用户端接口
 * @Date:2021/11/27 15:20
 * @Author:cxw
 */
@FeignClient("userModule")
public interface ConsumerService {

    //增加收货地址
    @PostMapping("/address/addAddress")
    public JSONObject addAddress(@RequestBody(required = false) JSONObject address);

    //根据id删除收货地址
    @PostMapping("/address/deleteAddressByAid")
    public JSONObject deleteAddressByAid(@RequestBody(required = false) JSONObject params);

    //根据id更新收货地址
    @PostMapping("/address/updateAddressByAid")
    public JSONObject updateAddressByAid(@RequestBody(required = false) JSONObject address);

    //查询用户所有收货地址
    @GetMapping("/address/getAddress")
    public JSONObject getAddress(@RequestParam(value = "phone",required = false) String phone);

    //首页分类展示商品
    @GetMapping("/goods/getGoodsByType")
    public JSONObject getGoodsByType(@RequestParam("type") String type,
                                     @RequestParam(value = "pagesNumber",required = false) Integer pagesNumber);

    //首页搜索倒叙输出
    @GetMapping("/goods/searchGoodsByName")
    public JSONObject searchGoodsByName(@RequestParam("name") String name,
                                        @RequestParam(value = "pagesNumber",required = false) Integer pagesNumber);

    //把商品加入购物车
    @PostMapping("/shopping/addShopping")
    public JSONObject addShopping(@RequestBody JSONObject jsonObject);

    //查询购物车 分页显示
    @GetMapping("/shopping/selectShopping")
    public JSONObject selectShopping(@RequestParam("phone") String phone,
                                     @RequestParam(value = "pagesNumber",required = false) Integer pagesNumber);

    //删除购物车
    @PostMapping("/shopping/deleteShopping")
    public JSONObject deleteShopping(@RequestBody JSONObject jsonObject);

    //购物车生成订单
    @PostMapping("/shopping/addOrderByShopping")
    public JSONObject addOrderByShopping(@RequestBody JSONObject params);

    //获取已付款订单,分页倒序
    @GetMapping("/order/getPaidOrdersByPhone")
    public JSONObject getPaidOrdersByPhone(@RequestParam(value = "phone",required = false) String phone,
                                           @RequestParam(value = "pagesNumber",required = false) Integer pagesNumber,
                                           @RequestParam(value = "status",required = false) Integer status);

    //根据oid获取未付款订单详情
    @GetMapping("/order/getOrderDetailByOid")
    public JSONObject getOrderDetailByOid(@RequestParam("oid") String oid);

    //对订单进行付款
    @PostMapping("/order/payToMoney")
    public JSONObject payToMoney(@RequestParam("oid") String oid,@RequestParam("aid") Integer aid);

    //商品详情页生成订单(生成的订单都是未付款的)
    @PostMapping("/order/addOrder")
    public JSONObject addOrder(@RequestBody JSONObject params);

    //取消订单,只能取消未付款的订单
    @PostMapping("/order/deleteOrdersByOid")
    public JSONObject deleteOrdersByOid(@RequestParam(value = "oid",required = false) String oid);

    //根据用户手机号查询指定用户
    @RequestMapping(value = "/userinfo/getUserInfoByPhone",method = RequestMethod.GET)
    public JSONObject getUserInfo(@RequestParam(value = "phone",required = false)String phone);

    //根据手机号更新用户信息
    @PostMapping(value = "/userinfo/updateUserInfo",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject updateUserInfo(@RequestParam("phone") String phone,
                                     @RequestParam(value = "name",required = false) String name,
                                     @RequestPart(value = "image",required = false) MultipartFile image,
                                     @RequestParam(value = "sex",required = false) Boolean sex,
                                     @RequestParam(value = "desc",required = false) String desc,
                                     @RequestParam(value = "email",required = false) String email,
                                     @RequestParam(value = "money",required = false) Double money);


    /*
    发布评论，
    用户只能在一个商品发布一个评论，管理员也只能回复一次。
     */
    @PostMapping(value = "/comment/addUserComment",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public JSONObject addUserComment(@RequestParam("text") String text,
                                     @RequestParam("pid") Integer pid,
                                     @RequestParam("phone") String phone,
                                     @RequestParam("oid") String oid,
                                     @RequestPart(value = "p1",required = false) MultipartFile p1);
}
